module winapi.winapi;

version (Windows)
{
	public import std.c.windows.windows;
	public import std.c.windows.winsock;
}
else
{
    static assert(0);		// Windows only
}

struct MOUSEINPUT
{
	LONG dx;
    LONG dy;
    DWORD mouseData;
    DWORD dwFlags;
    DWORD time;
    ULONG dwExtraInfo;
}

struct KEYBDINPUT
{
	WORD wVk;
    WORD wScan;
    DWORD dwFlags;
    DWORD time;
    ULONG dwExtraInfo;
}

struct INPUT
{
	DWORD type;
	union {
		MOUSEINPUT mi; 
        KEYBDINPUT ki;
	}
}

align(2) struct BITMAPFILEHEADER {
	  WORD bfType; 
	  DWORD bfSize; 
	  WORD bfReserved1; 
	  WORD bfReserved2; 
	  DWORD bfOffBits; 
	}

const uint INPUT_MOUSE = 0;
const uint INPUT_KEYBOARD = 1;
const uint MOUSEEVENTF_XDOWN = 0x80;
const uint MOUSEEVENTF_XUP = 0x100;
const uint MOUSEEVENTF_LEFTDOWN = 2;
const uint MOUSEEVENTF_LEFTUP = 4;

const uint BLACKONWHITE;
	
extern (Windows)
{
	typedef void function(
			        LPVOID lpArgToCompletionRoutine,
			        DWORD dwTimerLowValue,
			        DWORD dwTimerHighValue
			) PTIMERAPCROUTINE;
	
	UINT SendInput(      
		    UINT nInputs,
		    INPUT *pInputs,
		    int cbSize
		);
	
	HWND GetDesktopWindow();
	HBITMAP CreateCompatibleBitmap(
			  HDC hdc, 
			  int nWidth, 
			  int nHeight
			); 
	
	BOOL BitBlt(
			  HDC hdcDest, 
			  int nXDest, 
			  int nYDest, 
			  int nWidth, 
			  int nHeight, 
			  HDC hdcSrc, 
			  int nXSrc, 
			  int nYSrc, 
			  DWORD dwRop
			);
	
	int GetDIBits(
			       HDC hdc,
			       HBITMAP hbmp,
			       UINT uStartScan,
			       UINT cScanLines,
			      LPVOID lpvBits,
			    LPBITMAPINFO lpbi,
			       UINT uUsage
			);
	
	HANDLE  CreateWaitableTimerW(
			    LPSECURITY_ATTRIBUTES lpTimerAttributes,
			    BOOL bManualReset,
			    LPCWSTR lpTimerName
			);
	
	BOOL SetWaitableTimer(
			    HANDLE hTimer,
			    long *pDueTime,
			    LONG lPeriod,
			    PTIMERAPCROUTINE pfnCompletionRoutine,
			    LPVOID lpArgToCompletionRoutine,
			    BOOL fResume
			);
}